/*
 * @Author: jiu yin
 * @Date: 2024-04-09 11:14:36
 * @LastEditTime: 2024-04-25 17:32:28
 * @LastEditors: jiu yin zhen jing
 * @FilePath: \web-smart-tour\src\store\modules\map.js
 * jiu
 */

var cloneDeep = require('lodash/cloneDeep');
var amapFile = require('@/libs/amap-wx.130.js');
var amapPlugin = new amapFile.AMapWX({ key: '95110c8986c0183d2936a3861a6cfbcf' });
let init_map = {
	mock_open: false,
	map_nav_type: 'ar_nav', //ar_nav AR导航 map_nav 地图导航
	switch_value: true, //AI 开关
	answer_person: false, //回答人动画
	amapPlugin,
	change_map: {
		altitude: 0, //海拔
		speed: 0, //速度
		init_distance: 0, //距离
	},
	ai_loading: {
		question_loading: false, //问题加载
		answer_loading: false, //回答加载
	},
	clockModal: {
		show: false,
		title: '',
		id: '',
	}, //打卡弹窗
	markItem: {
		show: false,
		show_text: false,
	},
};
const state = () => ({
	map: cloneDeep(init_map),
});
const mutations = {
	set_map_nav_type(state, str) {
		return (state.map.map_nav_type = str);
	},
	set_switch_value(state, bool) {
		return (state.map.switch_value = bool);
	},
	set_change_map(state, obj) {
		return (state.map.change_map = { ...state.map.change_map, ...obj });
	},
	set_ai_loading(state, obj) {
		return (state.map.ai_loading = { ...state.map.ai_loading, ...obj });
	},
	set_clockModal(state, obj) {
		return (state.map.clockModal = { ...state.map.clockModal, ...obj });
	},
	set_answer_person(state, boolean) {
		return (state.map.answer_person = boolean);
	},
	set_mock_open(state, boolean) {
		return (state.map.mock_open = boolean);
	},
	set_mark_item(state, obj) {
		console.log(state.map.markItem, 'set=====');
		return (state.map.markItem = { ...state.map.markItem, ...obj });
	},
	reset(state) {
		return (state.map = init_map);
	},
};
const actions = {};

export default {
	state,
	mutations,
	actions,
	namespaced: true,
};
